//
//  TravelModel.m
//  MiaoTu
//
//  Created by dllo on 16/09/03
//  Copyright (c) dllo. All rights reserved.
//

#import "TravelModel.h"
#import "TravelItem.h"
#import "Banner.h"
#import "Topic.h"

@implementation TravelModel

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"Items"]) {
        NSMutableArray<TravelItem *> *itemArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            TravelItem *travelItem = [TravelItem modelWithDic:dic];
            [itemArray addObject:travelItem];
        }
        _Items = itemArray;
    }
    if ([key isEqualToString:@"Banner"]) {
        NSMutableArray<Banner *> *bannerArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            Banner *banner = [Banner modelWithDic:dic];
            [bannerArray addObject:banner];
        }
        _Banner = bannerArray;
    }
    if ([key isEqualToString:@"Topic"]) {
        NSMutableArray<Topic *> *topicArray = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            Topic *topic = [Topic modelWithDic:dic];
            [topicArray addObject:topic];
        }
        _Topic = topicArray;
    }
    if ([key isEqualToString:@"CityList"]) {
        NSMutableArray<NSString *> *stringArray = [NSMutableArray array];
        for (NSString *string in value) {
            [stringArray addObject:string];
        }
        _CityList = stringArray;
    }
}

+ (NSDictionary *)objectClassInArray{
    return @{@"Items" : [TravelItem class], @"Banner" : [Banner class], @"Topic" : [Topic class]};
}

@end
